import React from 'react';
import { createForm } from 'rc-form';
import { hashHistory} from 'react-router';
import { List,Tabs, WhiteSpace, Badge ,InputItem} from 'antd-mobile';
import '../car/less/index.less';

const Item = List.Item;
const nowTimeStamp = Date.now();
// const now = new Date(nowTimeStamp);
let value = {};

class OrderFills extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            goodName:'',
            goodPrice:'',
            goodIcon:'',
            goodIcon1:[]
        };
    }
    componentDidMount() {
        this.props.changeTitle('填写订单');
        this.setState({
            values: value
        });
    }
    componentWillMount(){
        value = this.props.location.state;
        this.dataValue();
    }
    chooserAddr = () => {
            hashHistory.push({
                pathname: '/car/chooseAddrs',
            })
    };
    changeView = (e) => {
        this.setState({
            listView:!this.state.listView

        })
    };
    dataValue= () => {

        if(value.goodsNum===1) {
            for (var a = 0; a < value.data.length; a++) {
                if (value.goodstate["good" + value.data[a].id]["checked"] == true) {
                    this.state.goodName = value.data[a].name;
                    this.state.goodIcon = value.data[a].icon;
                    this.state.goodPrice = value.data[a].price;
                    console.log(this.state.goodIcon[a])
                    console.log(value.goodstate)
                }
            }
        }else {
            for (var i = 0; i < value.data.length; i++) {
                if (value.goodstate["good" + value.data[i].id]["checked"] == true) {
                    // this.state.goodName = value.goodstate["good" + value.data[i].id]["name"];
                    this.state.goodName = value.data[i].name;
                    this.state.goodIcon1[i] = value.data[i].icon;
                    this.state.goodPrice = value.data[i].price;
                    console.log(this.state.goodIcon[i])
                    console.log(value.goodstate)
                }
            }
        }
}
    render() {

        // console.log(value.totalPrices);
        // console.log(value);
        // console.log(value.data);
        return (
            <div>
                <list>
                    <Item  onClick={this.chooserAddr}  arrow="horizontal"  thumb="http://192.168.0.131:8091/ecommerce/20171205170318.png" align="middle" wrap>
                        <div className="Item-addr-name">
                            刘一
                        </div>
                        <div>
                            <span className="Item-addr-font">
                                福建省福州市鼓楼区东街口7号省电信大楼西区14楼中兴软创科技股份有限公司
                            </span>
                        </div>
                    </Item>
                </list>
                <div className="div-img" >
                </div>
                <WhiteSpace/>
                {value.goodsNum === 1 ?
                    <div style={{width: '100%', height: '200px', backgroundColor: '#ffffff'}}>
                        <div style={{width: '25%', height: '85%', float: 'left'}}>
                            <img style={{height: '140px', width: '140px', marginLeft: '30px', marginTop: '30px'}}
                                 src={this.state.goodIcon}/>
                        </div>
                        <div style={{width: '100%', height: '85%'}} wrap>
                            <span style={{
                                fontFamily: 'PingFangSC-Regular',
                                fontSize: '80%',
                                color: '#333333',
                                marginTop: '50px'
                            }}>{this.state.goodName}</span>
                            <div style={{
                                fontFamily: 'PingFangSC-Regular',
                                fontSize: '100%',
                                color: '#ff323a',
                                marginLeft: '3%',
                                marginTop: '85px'
                            }}>￥{this.state.goodPrice}
                                <span style={{
                                    fontFamily: 'PingFangSC-Regular',
                                    fontSize: '80%',
                                    color: '#999999',
                                    marginTop: '85px',
                                    marginLeft: '55%'
                                }}>x{value.nums}</span>
                            </div>
                        </div>
                    </div>
                    :
                    <list>
                        <Item extra={'共'+value.goodsNum+'件'} arrow="horizontal">
                            <img style={{height: '140px', width: '140px', marginRight: '20px'}}
                                 src={this.state.goodIcon1[2]} alt=""/>
                            <img style={{height: '140px', width: '140px', marginRight: '20px'}}
                                 src={this.state.goodIcon1[1]} alt=""/>
                            <img style={{height: '140px', width: '140px', marginRight: '20px'}}
                                 src={this.state.goodIcon1[0]} alt=""/>
                        </Item>
                    </list>
                }


                <WhiteSpace/>
                <list>
                    <InputItem >备注(选填)</InputItem>
                </list>
                <WhiteSpace/>
                <list>
                    <Item  arrow="horizontal" >选择红包</Item>
                </list>
                <WhiteSpace/>
                <list >
                    <Item extra={'不需要'} arrow="horizontal" onClick={this.changeView}>发票信息</Item>
                </list>
                <WhiteSpace/>
                <div className="order-submit">
                    <div style={{float:'left',width:'75%',height:'100%',textAlign:'center'}}>
                        <div style={{height:'1.2rem',marginLeft:'25%',textAlign:'center'}}>
                            <div style={{float:'left',fontFamily:'PingFangSC-Medium',lineHeight:'1.2rem',height:'1.2rem',color:'#333333',marginLeft:'32%'}}>实付款：</div>
                            <div style={{fontFamily:'PingFangSC-Regular',lineHeight:'1.2rem',height:'1.2rem',color:'#ff323a'}}>￥{value.totalPrices}</div>
                        </div>
                    </div>
                    <div  style={{width:'25%',backgroundColor:'#ff6215',float:'right',height:'1.2rem',textAlign:'center'}}>
                        <div style={{color:'#ffffff',textAlign:'center',height:'1.2rem',lineHeight:'1.2rem'}}>提交订单</div>
                    </div>
                </div>
            </div>
        );
    }
}

export default createForm()(OrderFills);
